/***
 * * PROJECT
 * *    Logical Neighborhood Routing
 * * VERSION
 * *    $Revision: 1.1 $
 * * DATE
 * *    $Date: 2007/01/10 22:57:04 $
 * * LOG
 * *    $Log: LNStaticHelper.java,v $
 * *    Revision 1.1  2007/01/10 22:57:04  lmottola
 * *    LNStaticHelper added.
 * *
 * *
 * *
 * *   Logical Neighborhoods Routing - Java Version
 * *
 * *   This program is free software; you can redistribute it and/or
 * *   modify it under the terms of the GNU General Public License
 * *   as published by the Free Software Foundation; either version 2
 * *   of the License, or (at your option) any later version.
 * *
 * *   This program is distributed in the hope that it will be useful,
 * *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * *   GNU General Public License for more details.
 * *
 * *   You should have received a copy of the GNU General Public License
 * *   along with this program; if not, you may find a copy at the FSF web
 * *   site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
 * *   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * *   Boston, MA  02111-1307, USA
 ***/

package atag.runtime.ln.estimation;

import java.util.Iterator;
import java.util.LinkedList;

import atag.common.NetworkTopology;
import atag.runtime.NodeInfo;
import atag.runtime.ln.LNScope;

/**
 * This class implements a helper method that returns the set of node ids
 * matching a particular scope given a network topology. It is used during the
 * compilation process, as well as for off-line estimation of communication
 * costs.
 * 
 * @author Luca Mottola <a
 *         href="mailto:mottola@elet.polimi.it">mottola@elet.polimi.it</a>
 * 
 */
public class LNStaticHelper {

	public static LinkedList<Integer> determineMatchingNodes(
			NetworkTopology topology, LNScope scope) {

		LinkedList<NodeInfo> nodes = new LinkedList<NodeInfo>(topology
				.getNodes());
		LinkedList<Integer> res = new LinkedList<Integer>();
		Iterator<NodeInfo> it = nodes.iterator();
		while (it.hasNext()) {
			NodeInfo nodeInfo = it.next();
			if (scope.matches(nodeInfo)) {
				res.add(nodeInfo.getMyId());
			}
		}
		return res;
	}
}
